import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class loginservlet extends HttpServlet {

	@Override
	protected void doGet(HttpServletRequest request,
			HttpServletResponse response) throws ServletException, IOException {
		processRequest(request, response);
	}

	@Override
	protected void doPost(HttpServletRequest request,
			HttpServletResponse response)

	throws ServletException, IOException {

		processRequest(request, response);

	}

	protected void processRequest(HttpServletRequest request,
			HttpServletResponse response)

	throws ServletException, IOException {
		String id = request.getParameter("userid");
		String pwd = request.getParameter("pwd");
		if (id.equals("admin") && pwd.equals("cmsadmin")) {

			response.sendRedirect("welcome_admin.html");

		} else if (id.equals("staff") && pwd.equals("cmsstaff")) {

			response.sendRedirect("staff_home.html");

		} else {
			response.sendRedirect("loginfail.html");

		}



					}
}
